usbmuxd-1.1.1^20240915git0b1b233-5.fc43

List of Findings

Error: CPPCHECK_WARNING (CWE-476): [#def1]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:216: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  214|   	struct mux_client *client;
#  215|   	client = malloc(sizeof(struct mux_client));
#  216|-> 	memset(client, 0, sizeof(struct mux_client));
#  217|   
#  218|   	client->fd = cfd;

Error: CPPCHECK_WARNING (CWE-476): [#def2]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:218: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  216|   	memset(client, 0, sizeof(struct mux_client));
#  217|   
#  218|-> 	client->fd = cfd;
#  219|   	client->ob_buf = malloc(REPLY_BUF_SIZE);
#  220|   	client->ob_size = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def3]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:219: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  217|   
#  218|   	client->fd = cfd;
#  219|-> 	client->ob_buf = malloc(REPLY_BUF_SIZE);
#  220|   	client->ob_size = 0;
#  221|   	client->ob_capacity = REPLY_BUF_SIZE;

Error: CPPCHECK_WARNING (CWE-476): [#def4]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:220: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  218|   	client->fd = cfd;
#  219|   	client->ob_buf = malloc(REPLY_BUF_SIZE);
#  220|-> 	client->ob_size = 0;
#  221|   	client->ob_capacity = REPLY_BUF_SIZE;
#  222|   	client->ib_buf = malloc(CMD_BUF_SIZE);

Error: CPPCHECK_WARNING (CWE-476): [#def5]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:221: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  219|   	client->ob_buf = malloc(REPLY_BUF_SIZE);
#  220|   	client->ob_size = 0;
#  221|-> 	client->ob_capacity = REPLY_BUF_SIZE;
#  222|   	client->ib_buf = malloc(CMD_BUF_SIZE);
#  223|   	client->ib_size = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def6]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:222: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  220|   	client->ob_size = 0;
#  221|   	client->ob_capacity = REPLY_BUF_SIZE;
#  222|-> 	client->ib_buf = malloc(CMD_BUF_SIZE);
#  223|   	client->ib_size = 0;
#  224|   	client->ib_capacity = CMD_BUF_SIZE;

Error: CPPCHECK_WARNING (CWE-476): [#def7]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:223: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  221|   	client->ob_capacity = REPLY_BUF_SIZE;
#  222|   	client->ib_buf = malloc(CMD_BUF_SIZE);
#  223|-> 	client->ib_size = 0;
#  224|   	client->ib_capacity = CMD_BUF_SIZE;
#  225|   	client->state = CLIENT_COMMAND;

Error: CPPCHECK_WARNING (CWE-476): [#def8]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:224: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  222|   	client->ib_buf = malloc(CMD_BUF_SIZE);
#  223|   	client->ib_size = 0;
#  224|-> 	client->ib_capacity = CMD_BUF_SIZE;
#  225|   	client->state = CLIENT_COMMAND;
#  226|   	client->events = POLLIN;

Error: CPPCHECK_WARNING (CWE-476): [#def9]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:225: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  223|   	client->ib_size = 0;
#  224|   	client->ib_capacity = CMD_BUF_SIZE;
#  225|-> 	client->state = CLIENT_COMMAND;
#  226|   	client->events = POLLIN;
#  227|   	client->info = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def10]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:226: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  224|   	client->ib_capacity = CMD_BUF_SIZE;
#  225|   	client->state = CLIENT_COMMAND;
#  226|-> 	client->events = POLLIN;
#  227|   	client->info = NULL;
#  228|   

Error: CPPCHECK_WARNING (CWE-476): [#def11]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:227: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  225|   	client->state = CLIENT_COMMAND;
#  226|   	client->events = POLLIN;
#  227|-> 	client->info = NULL;
#  228|   
#  229|   	mutex_lock(&client_list_mutex);

Error: CPPCHECK_WARNING (CWE-476): [#def12]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:230: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: client
#  228|   
#  229|   	mutex_lock(&client_list_mutex);
#  230|-> 	client->number = client_number++;
#  231|   	collection_add(&client_list, client);
#  232|   	mutex_unlock(&client_list_mutex);

Error: CPPCHECK_WARNING (CWE-476): [#def13]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:470: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: progname
#  468|   				progname = strdup("unknown");
#  469|   			}
#  470|-> 			char *idstring = malloc(strlen(progname) + 12);
#  471|   			sprintf(idstring, "%u-%s", client->number, progname);
#  472|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def14]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:470:49: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘progname’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:957:6: enter_function: entry to ‘client_process’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:961:9: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:961:9: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:969:11: branch_false: following ‘false’ branch (when ‘client’ is non-NULL)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:974:12: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:974:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:978:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:978:19: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:979:25: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:979:25: call_function: calling ‘input_buffer_process’ from ‘client_process’
#argument 1 of ‘__builtin_strlen’ must be non-null
#  468|   				progname = strdup("unknown");
#  469|   			}
#  470|-> 			char *idstring = malloc(strlen(progname) + 12);
#  471|   			sprintf(idstring, "%u-%s", client->number, progname);
#  472|   

Error: CPPCHECK_WARNING (CWE-476): [#def15]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:471: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: progname
#  469|   			}
#  470|   			char *idstring = malloc(strlen(progname) + 12);
#  471|-> 			sprintf(idstring, "%u-%s", client->number, progname);
#  472|   
#  473|   			plist_dict_set_item(l, "ID String", plist_new_string(idstring));

Error: GCC_ANALYZER_WARNING (CWE-688): [#def16]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:471:25: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘idstring’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:957:6: enter_function: entry to ‘client_process’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:961:9: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:961:9: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:969:11: branch_false: following ‘false’ branch (when ‘client’ is non-NULL)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:974:12: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:974:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:978:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:978:19: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:979:25: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/client.c:979:25: call_function: calling ‘input_buffer_process’ from ‘client_process’
#argument 1 of ‘__builtin_sprintf’ must be non-null
#  469|   			}
#  470|   			char *idstring = malloc(strlen(progname) + 12);
#  471|-> 			sprintf(idstring, "%u-%s", client->number, progname);
#  472|   
#  473|   			plist_dict_set_item(l, "ID String", plist_new_string(idstring));

Error: GCC_ANALYZER_WARNING (CWE-476): [#def17]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:210:25: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘uuid’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:369:6: enter_function: entry to ‘config_get_system_buid’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:375:12: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:380:12: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:380:12: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:383:14: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:383:12: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:385:17: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:386:32: call_function: inlined call to ‘config_generate_system_buid’ from ‘config_get_system_buid’
#  208|   			continue;
#  209|   		} else {
#  210|-> 			uuid[i] = chars[get_rand(0, 16)];
#  211|   		}
#  212|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def18]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/conf.c:214: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: uuid
#  212|   	}
#  213|   	/* make it a real string */
#  214|-> 	uuid[36] = '\0';
#  215|   	return uuid;
#  216|   }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def19]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:219:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘buffer’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:830:5: enter_function: entry to ‘device_add’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:850:19: call_function: calling ‘send_packet’ from ‘device_add’
#  217|   	buffer = malloc(total);
#  218|   	struct mux_header *mhdr = (struct mux_header *)buffer;
#  219|-> 	mhdr->protocol = htonl(proto);
#  220|   	mhdr->length = htonl(total);
#  221|   	if (dev->version >= 2) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def20]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:235:11: warning[-Wanalyzer-malloc-leak]: leak of ‘buffer’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:830:5: enter_function: entry to ‘device_add’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:850:19: call_function: calling ‘send_packet’ from ‘device_add’
#  233|   		memcpy(buffer + mux_header_size + hdrlen, data, length);
#  234|   
#  235|-> 	if((res = usb_send(dev->usbdev, buffer, total)) < 0) {
#  236|   		usbmuxd_log(LL_ERROR, "usb_send failed while sending packet (len %d) to device %d: %d", total, dev->id, res);
#  237|   		free(buffer);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def21]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:837:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘dev’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:836:15: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:837:9: danger: ‘dev’ could be NULL: unchecked value from [(1)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/0)
#  835|   	usbmuxd_log(LL_NOTICE, "Connecting to new device on location 0x%x as ID %d", usb_get_location(usbdev), id);
#  836|   	dev = malloc(sizeof(struct mux_device));
#  837|-> 	dev->id = id;
#  838|   	dev->usbdev = usbdev;
#  839|   	dev->state = MUXDEV_INIT;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def22]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:945:25: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘p’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:940:20: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:943:9: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:943:9: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:943:9: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:944:21: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:944:19: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:944:20: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/device.c:945:25: danger: ‘p’ could be NULL: unchecked value from [(1)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/0)
#  943|   	FOREACH(struct mux_device *dev, &dev_list) {
#  944|   		if((dev->state == MUXDEV_ACTIVE) && (include_hidden || dev->visible)) {
#  945|-> 			p->id = dev->id;
#  946|   			p->serial = usb_get_serial(dev->usbdev);
#  947|   			p->location = usb_get_location(dev->usbdev);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def23]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:75:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fs’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:69:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:72:26: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:72:14: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:74:11: branch_true: following ‘true’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:75:17: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:75:17: danger: argument 1 (‘fs’) from [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2) could be NULL where non-null expected
#argument 1 of ‘__builtin_sprintf’ must be non-null
#   73|   
#   74|   	if(log_syslog) {
#   75|-> 		sprintf(fs, "[%d] %s\n", level, fmt);
#   76|   	} else {
#   77|   		struct timeval ts;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def24]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:88:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘fs’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:69:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:72:26: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:72:14: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:74:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:81:17: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/log.c:88:17: danger: argument 1 (‘fs’) from [(3)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/2) could be NULL where non-null expected
#   86|   #endif
#   87|   
#   88|-> 		strftime(fs, 10, "[%H:%M:%S", tp);
#   89|   		sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
#   90|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def25]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:100: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: hostname
#   98|   		int res;
#   99|   
#  100|-> 		strncpy(hostname, socket_addr, nlen-1);
#  101|   		hostname[nlen-1] = '\0';
#  102|   

Error: CPPCHECK_WARNING (CWE-476): [#def26]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:101: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: hostname
#   99|   
#  100|   		strncpy(hostname, socket_addr, nlen-1);
#  101|-> 		hostname[nlen-1] = '\0';
#  102|   
#  103|   		memset(&hints, '\0', sizeof(struct addrinfo));

Error: GCC_ANALYZER_WARNING (CWE-775): [#def27]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:408:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:407:12: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:410:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:410:11: branch_false: following ‘false’ branch (when ‘res >= 0’)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:415:15: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:416:12: branch_true: following ‘true’ branch (when ‘pid < 0’)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:417:17: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:408:24: danger: ‘pfd[0]’ leaks here
#  406|   	// already a daemon
#  407|   	if (getppid() == 1)
#  408|-> 		return 0;
#  409|   
#  410|   	if((res = pipe(pfd)) < 0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def28]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:408:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[1]’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:407:12: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:410:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:410:11: branch_false: following ‘false’ branch (when ‘res >= 0’)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:415:15: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:416:12: branch_true: following ‘true’ branch (when ‘pid < 0’)...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:417:17: branch_true: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/main.c:408:24: danger: ‘pfd[1]’ leaks here
#  406|   	// already a daemon
#  407|   	if (getppid() == 1)
#  408|-> 		return 0;
#  409|   
#  410|   	if((res = pipe(pfd)) < 0) {

Error: CPPCHECK_WARNING (CWE-476): [#def29]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:137: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  135|   	struct device_info *info = (struct device_info*)userdata;
#  136|   	struct idevice_private *_dev = (struct idevice_private*)malloc(sizeof(struct idevice_private));
#  137|-> 	_dev->udid = strdup(info->serial);
#  138|   	_dev->mux_id = info->id;
#  139|   	_dev->conn_type = CONNECTION_USBMUXD;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def30]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:137:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘_dev’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:136:65: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:137:9: danger: ‘_dev’ could be NULL: unchecked value from [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  135|   	struct device_info *info = (struct device_info*)userdata;
#  136|   	struct idevice_private *_dev = (struct idevice_private*)malloc(sizeof(struct idevice_private));
#  137|-> 	_dev->udid = strdup(info->serial);
#  138|   	_dev->mux_id = info->id;
#  139|   	_dev->conn_type = CONNECTION_USBMUXD;

Error: CPPCHECK_WARNING (CWE-476): [#def31]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:138: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  136|   	struct idevice_private *_dev = (struct idevice_private*)malloc(sizeof(struct idevice_private));
#  137|   	_dev->udid = strdup(info->serial);
#  138|-> 	_dev->mux_id = info->id;
#  139|   	_dev->conn_type = CONNECTION_USBMUXD;
#  140|   	_dev->conn_data = NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def32]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:139: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  137|   	_dev->udid = strdup(info->serial);
#  138|   	_dev->mux_id = info->id;
#  139|-> 	_dev->conn_type = CONNECTION_USBMUXD;
#  140|   	_dev->conn_data = NULL;
#  141|   	_dev->version = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def33]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:140: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  138|   	_dev->mux_id = info->id;
#  139|   	_dev->conn_type = CONNECTION_USBMUXD;
#  140|-> 	_dev->conn_data = NULL;
#  141|   	_dev->version = 0;
#  142|   	_dev->device_class = 0;

Error: CPPCHECK_WARNING (CWE-476): [#def34]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:141: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  139|   	_dev->conn_type = CONNECTION_USBMUXD;
#  140|   	_dev->conn_data = NULL;
#  141|-> 	_dev->version = 0;
#  142|   	_dev->device_class = 0;
#  143|   

Error: CPPCHECK_WARNING (CWE-476): [#def35]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:142: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  140|   	_dev->conn_data = NULL;
#  141|   	_dev->version = 0;
#  142|-> 	_dev->device_class = 0;
#  143|   
#  144|   	idevice_t dev = (idevice_t)_dev;

Error: CPPCHECK_WARNING (CWE-476): [#def36]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:153: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: _dev
#  151|   	char* deviceclass_str = NULL;
#  152|   
#  153|-> 	usbmuxd_log(LL_INFO, "%s: Starting preflight on device %s...", __func__, _dev->udid);
#  154|   
#  155|   retry:

Error: CPPCHECK_WARNING (CWE-476): [#def37]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:388: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: infocopy
#  386|   	struct device_info *infocopy = (struct device_info*)malloc(sizeof(struct device_info));
#  387|   
#  388|-> 	memcpy(infocopy, info, sizeof(struct device_info));
#  389|   	if (info->serial) {
#  390|   		infocopy->serial = strdup(info->serial);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def38]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:388:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘infocopy’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:380:12: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:386:61: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/preflight.c:388:9: danger: argument 1 (‘infocopy’) from [(3)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/2) could be NULL where non-null expected
#argument 1 of ‘__builtin_memcpy’ must be non-null
#  386|   	struct device_info *infocopy = (struct device_info*)malloc(sizeof(struct device_info));
#  387|   
#  388|-> 	memcpy(infocopy, info, sizeof(struct device_info));
#  389|   	if (info->serial) {
#  390|   		infocopy->serial = strdup(info->serial);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def39]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:773:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘usbdev’ where non-null expected
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:745:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:750:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:750:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:754:12: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:754:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:756:13: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:756:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:763:9: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:766:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:772:18: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:772:18: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:773:9: danger: argument 1 (‘usbdev’) from [(11)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/10) could be NULL where non-null expected
#argument 1 of ‘__builtin_memset’ must be non-null
#  771|   	// Add the created handle to the device list, so we can close it in case of failure/disconnection
#  772|   	usbdev = malloc(sizeof(struct usb_device));
#  773|-> 	memset(usbdev, 0, sizeof(*usbdev));
#  774|   
#  775|   	usbdev->serial[0] = 0;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def40]
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:795:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘context’
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:745:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:750:19: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:750:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:754:12: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:754:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:756:13: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:756:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:763:9: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:766:11: branch_false: following ‘false’ branch...
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:772:18: branch_false: ...to here
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:794:40: acquire_memory: this call could return NULL
usbmuxd-0b1b233b57d581515978a09e5a4394bfa4ee4962/src/usb.c:795:9: danger: ‘context’ could be NULL: unchecked value from [(11)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/10)
#  793|   	usbmuxd_log(LL_INFO, "Requesting current mode from device %i-%i", bus, address);
#  794|   	struct mode_context* context = malloc(sizeof(struct mode_context));
#  795|-> 	context->dev = dev;
#  796|   	context->bus = bus;
#  797|   	context->address = address;

Scan Properties

analyzer-version-clippy1.86.0
analyzer-version-cppcheck2.17.1
analyzer-version-gcc15.0.1
analyzer-version-gcc-analyzer15.0.1
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-206.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250425.124705.g1c7c448.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-nameusbmuxd-1.1.1^20240915git0b1b233-5.fc43
store-results-to/tmp/tmpack83cf9/usbmuxd-1.1.1^20240915git0b1b233-5.fc43.tar.xz
time-created2025-04-25 15:57:59
time-finished2025-04-25 15:59:13
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'unicontrol,cppcheck,gcc,clippy,shellcheck' '-o' '/tmp/tmpack83cf9/usbmuxd-1.1.1^20240915git0b1b233-5.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpack83cf9/usbmuxd-1.1.1^20240915git0b1b233-5.fc43.src.rpm'
tool-versioncsmock-3.8.1.20250422.172604.g26bc3d6-1.el9